<include file="Public/min-header"/>
<link href="__PUBLIC__/plugins/daterangepicker/daterangepicker-bs3.css" rel="stylesheet" type="text/css" />
<script src="__PUBLIC__/plugins/daterangepicker/moment.min.js" type="text/javascript"></script>
<script src="__PUBLIC__/plugins/daterangepicker/daterangepicker.js" type="text/javascript"></script>
<div class="wrapper">
    <!-- Content Header (Page header) -->
    <include file="Public/breadcrumb"/>
    <!-- Main content -->
    <section class="content">
        <div class="container-fluid">
            <div class="panel panel-default">
                <div class="panel-heading">
                    <h3 class="panel-title"><i class="fa fa-list"></i> 订单列表</h3>
                </div>
                <div class="panel-body new-panel-body">
                    <div class="navbar">
                        <form action="#" id="search-form2" class="navbar-form form-inline" method="post">
                            <div class="form-group">
                                <div class="input-group">
                                    <input type="text" name="order_sn" id="order_sn" placeholder="订单编号" id="input-order-id" class="form-control">
                                </div>
                            </div>
                            <div class="form-group">
                                <div class="input-group">
                                    <input type="text" name="consignee" id="consignee" placeholder="收货人/档铺名/手机" id="input-member-id" class="form-control">
                                </div>
                            </div>
                            <div class="form-group">
                                <div class="input-group">
                                    <input type="text" name="goods_name" id="goods_name" placeholder="产品名称" id="input-order-id" class="form-control" style="border:1px solid #337ab7;width:150px;">
                                </div>
                            </div>
                            <div class="form-group">
                                <div class="input-group">
                                    <input type="text" name="timegap" value="{$timegap}" placeholder="下单日期"  id="add_time" class="form-control" style="width: 220px;">
                                </div>
                            </div>
                            <!--                                <div class="form-group">
                                                                <select name="pay_status" class="input-sm" style="width:100px;">
                                                                        <option value="">支付状态</option>
                                                                        <option value="0">未支付</option>
                                                                  <option value="1">已支付</option>
                                                                </select>
                                                            </div>
                                                            <div class="form-group">
                                                                <select name="pay_code" class="input-sm" style="width:100px;">
                                                                        <option value="">支付方式</option>
                                                                        <option value="alipay">支付宝支付</option>
                                                                          <option value="weixin">微信支付</option>
                                                                          <option value="cod">货到付款</option>
                                                                </select>
                                                            </div> -->
                            <!--                                <div class="form-group">
                                                                <select name="shipping_status" class="input-sm" style="width:100px;">
                                                                        <option value="">发货状态</option>
                                                                        <option value="0">未发货</option>
                                                                          <option value="1">已发货</option>
                                                                          <option value="2">部分发货</option>
                                                                </select>
                                                            </div> -->
                            <div class="form-group">
                                <?php
									if(I('order_status')==""){
									?>
                                <select name="order_status" class="form-control" style="width:110px;">
                                    <option value="">订单状态</option>
                                    <volist name="order_status" id="v" key="k">
                                        <option value="{$k-1}">{$v}</option>
                                    </volist>
                                </select>
                                <?php
									}elseif(I('order_status')!=""){
										echo '<input type="hidden" name="order_status" id="order_status" value="'.I('order_status').'">';
                                }else{
                                echo '<input type="hidden" name="order_status" id="order_status" value="35">';
                                }
                                ?>
                                <input type="hidden" name="order_by" value="order_id">
                                <input type="hidden" name="sort" value="desc">
                            </div>
                            <div class="form-group" style="margin-left:13px;">
                                <a href="javascript:void(0)" onclick="ajax_get_table('search-form2',1)" id="button-filter search-order" class="btn btn-primary"><i class="fa fa-search"></i> 筛选</a>
                            </div>
<!--                            <div class="form-group" style="margin-left:13px;">-->
<!--                                <a href="/index.php?m=Seller&c=Order&a=add_order" class="btn btn-primary"><i class="fa fa-plus"></i> 代客下单</a>-->
<!--                            </div>-->
<!--                            <button type="button" class="btn btn-primary pull-right" id="daochu"><i class="fa fa-file-excel-o"></i>&nbsp;导出excel</button>-->
                        </form>
                        <span style="color: red; padding: 5px 15px; display: block;">温馨提醒：商家只需打印单据、标签进行拣货包装，捡好货后把货送到仓库即可！订单状态和收付款平台自动化。<b>（如有需合并、拆单，先合并或者拆单再打印标签！）</b></span>
                    </div>
                    <input type="hidden" value="{$syncname}" id="syncname">
                    <div id="ajax_return">

                    </div>

                </div>
            </div>
        </div>        <!-- /.row -->
    </section>
    <!-- /.content -->
</div>
<!-- /.content-wrapper -->
<script>
    $(document).ready(function(){
        ajax_get_table('search-form2',1);

        $('#add_time').daterangepicker({
            format:"YYYY-MM-DD HH:mm",
            singleDatePicker: false,
            showDropdowns: true,
            minDate:'2021-01-01 00:00',
            maxDate:'2030-01-01 00:00',
            startDate:'{:date("Y-m-d")} 00:00',
            showWeekNumbers: true,
            timePicker: true,
            timePickerIncrement: 1,
            timePicker12Hour: false,
            ranges: {
                '今天': [moment(), moment()],
                '昨天': [moment().subtract('days', 1), moment().subtract('days', 1)],
                '最近7天': [moment().subtract('days', 6), moment()],
                '最近30天': [moment().subtract('days', 29), moment()],
                '上一个月': [moment().subtract('month', 1).startOf('month'), moment().subtract('month', 1).endOf('month')]
            },
            opens: 'left',
            buttonClasses: ['btn btn-default'],
            applyClass: 'btn-small btn-primary',
            cancelClass: 'btn-small',
            locale : {
                applyLabel : '确定',
                cancelLabel : '取消',
                fromLabel : '起始时间',
                toLabel : '结束时间',
                customRangeLabel : '自定义',
                daysOfWeek : [ '日', '一', '二', '三', '四', '五', '六' ],
                monthNames : [ '一月', '二月', '三月', '四月', '五月', '六月','七月', '八月', '九月', '十月', '十一月', '十二月' ],
                firstDay : 1
            }
        });

    });

    $("input[name=order_sn],input[name=consignee]").keydown(function(e){
        if (e.keyCode == "13") {
            ajax_get_table('search-form2',1);
        };
    });

    $("#daochu").click(function(){
        var order_sn=$("#order_sn").val();
        var consignee=$("#consignee").val();
        var add_time=$("#add_time").val();
        var order_status=$("#order_status").val();
        order_status==undefined?order_status="":order_status;
        location.href="/index.php/Seller/order/export_order?order_sn="+order_sn+"&consignee="+consignee+"&timegap="+add_time+"&order_status="+order_status;
    })

    // ajax 抓取页面
    function ajax_get_table(tab,page){
        cur_page = page; //当前页面 保存为全局变量
        var syncname = $('#syncname').val();
        var tag = "{$tag}";
        var arr = $('#'+tab).serialize()+'&p='+page+'&seller_name='+syncname;
        console.log(arr)
        $.ajax({
            type : "POST",
            url:'{$url}'+"/index.php/WXAPI/sync/ajaxindex/p/"+page+"/seller_name/"+syncname+"/tag/"+tag,//+tab,
            data : arr,// 你的formid
            success: function(data){
                $("#ajax_return").html('');
                $("#ajax_return").append(data);
            }
        });
    }

    // 点击排序
    function sort(field)
    {
        $("input[name='order_by']").val(field);
        var v = $("input[name='sort']").val() == 'desc' ? 'asc' : 'desc';
        $("input[name='sort']").val(v);
        ajax_get_table('search-form2',cur_page);
    }
    //批量打印操作提交
    function dayin(type) {
        //prompt层
        var ids = get_select_order_id_str();
        if (ids == false) {
            layer.alert('请勾选要打印的订单', {icon: 2});
            return;
        }
        layer.open({
            type: 2,
            title: '批量打印预览',
            shadeClose: true,
            shade: 0.3,
            area: ['80%', '80%'],
            content:'/index.php/Seller/Order/order_print_pl/order_ids/'+ids,
        });
    }
</script>
</body>
</html>